package com.example.weather.service.impl;

import com.example.weather.client.WeatherClient;
import com.example.weather.entity.CityCode;
import com.example.weather.mapper.CitcodeMapper;
import com.example.weather.mapper.UserMapper;
import com.example.weather.pojo.UserVo;
import com.example.weather.pojo.WeatherVo;
import com.example.weather.service.WeatherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class WeatherServiceImpl implements WeatherService {
    @Autowired
    private WeatherClient weatherClient;
    @Autowired
    private CitcodeMapper citcodeMapper;
    @Autowired
    private UserMapper userMapper;

    @Override
    public WeatherVo getWeather(String city) {
       CityCode cityCode = citcodeMapper.selectByCity(city);
        log.info("---------cityCode:{}",cityCode);
        return weatherClient.getWeather(cityCode.getAdCode());
//        WeatherResponseMapper weatherResponseMapper = new WeatherResponseMapper();
//        return weatherResponseMapper.toJson(vo);
    }

    @Override
    public void pushWeather() {
     List<UserVo> users  = userMapper.selectAllUser();

    }
}
